home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 10
/
AACD 10.iso
/
AACD
/
Resources
/
System
/
BoingBag1
/
Contributions
/
Workbench
/
C
/
find.doc
< prev
Wrap
Text File
|
1999-10-03
|
10KB
|
299 lines
Short: File Finder (custom search and output)
Author: soenke@vapor.com (Sönke Tesch)
Uploader: soenke@vapor.com
Type: util/dir
Replaces: util/dir/Find.lha
Keywords: Find Search File
Interface: CLI Shell
What`s it all about?
====================
This is probably the 10315th implementation of a File Finder. Anyway,
I spend a full 2½ hours on the first version, even got some mails and
therefore I like it best and and wrote a smarter update :)
Find will search in a directory and its subdirectories for objects
matching a given pattern. You can say where, where not and how deep
Find should search and if it should return only files or directories
or both.
The output is customizable similar to c:lists` LFORMAT option.
Find does not need any extra libraries nor does it feature a text viewer,
database or coffee-machine. Want a fancy MUI user interface with fifty-
thousand buttons? Go and look for another program, Find is CLI-only ,)
How to use
==========
Find PATTERN/A,LOCATIONS=ROOTDIR/M,DEPTH/N/K,DIRS/S,FILES/S,HEADER=STATS/S,
QUIET/S,PRINTSEARCHED/S,PRINTSKIPPED/S,LFORMAT=FORMAT/K
PATTERN
Name of the file or directory you are looking for. This string may
also contain standard AmigaDOS wildcards like #,?,~ etc. Please see
your AmigaDOS manual for further details.
Find doesn`t support paths here (e.g. txt/Hello) and will return
error code 210 (Invalid Component Name) in this case.
LOCATIONS (former ROOTDIR)
Find usually starts searching in the current directory and its sub-
directories. To let you search in other places the argument ROOTDIR
was defined in version 1. This argument has been extended and renamed
to LOCATIONS for Find².
You may now give any number (well, actually 255;) of directories to
search in. These names may also contain wildcards.
Furthermore you can exclude directories from the search by using a
- or a ! as the first character. There`s a small difference between
the - and the !: ! will exclude _any_ directory that matches the
given name regardless where it`s located. Like PATTERN ! works with
path-less directory names only (i.e. with "blabla" but not with
"txt/blabla").
NOTE:
To exclude a directory means to exclude all its subdirectories, too!
However, you may of course include a subdirectory of an excluded
directory.
Take the following directory structure as an example:
----------------------------------------------------------------------
1> dir all ;; current directory is Find
txt (dir)
test (dir)
test2
Find.mod Find.mod_2.0
Test.mod
obj (dir)
Find.obj Test.obj
testdir1 (dir)
testdir2 (dir)
test1
cmc.opt Find
Find.lha find.mtx
find.readme test
test.mtx
1> find test?
txt/test/test2
testdir1/testdir2/test1
1> find test? test#? printsearched
Scanning testdir1
Scanning testdir1/testdir2
testdir1/testdir2/test1
1> find #?st(?|%|.m[a-y]d) ;; AmigaDOS wildcards are powerfull! :)
txt/test
txt/test/test2
txt/Test.mod
txt/testdir1/testdir2/test1
test
1> find test? !test#? printsearched printskipped
Scanning txt
Skipped txt/test
Scanning obj
Skipped testdir1
1> find test? -txt/test#? printskipped
Skipped txt/test
testdir1/testdir2/test1
1> find test? -test#? printskipped
txt/test/test2
Skipped testdir1
1> find test? !txt/test#? printskipped
txt/test/test2
testdir1/testdir2/test1
;; didn`t work: ! doesn`t support paths
----------------------------------------------------------------------
+ is also supported as first character. This will do exactly the same
as if you omit it; it`s just there for completeness.
NOTE:
· If you have a name that starts with +, - or ! you`ll have to
put one of +, - or ! in front of it in order to make it work
correctly!
· Use "-Mr Spacey:blabla" instead of -"Mr Spacey:blabla"!
DEPTH
Maximum level of sub-directories Find will search in. The current
directory (or LOCATION if used) is level 0.
find EggPaint dh0: depth 0
will thus search only in the root of dh0:.
The default is unlimited.
NOTE:
If Find finds a matching link it will return the path and filename
of the file the link points to, _not_ of the link! Therefore you
may get files very deep in your directory tree although you set
DEPTH to 1 or even 0. This is not my fault, it`s just the way
the NameFromLock() function in dos.library works.
DIRS
Find returns only directories matching PATTERN.
FILES
Find returns only files matching PATTERN.
HEADER (former STATS)
Find will print some extra information after the search, e.g.
1 files and 5 directories in 2 of 7 places (0 skipped)
This obviously means Find found 1 matching file and 5 matching
directories in 2 directories. Find searched in a total of 7
directories and skipped 0.
QUIET
By default Find prints some information about where it is currently
looking for matching objects to the Shell window. This output can be
switched off by setting QUIET.
QUIET doesn`t affect output of PRINTSEARCHED and PRINTSKIPPED, so
if both of these are set, QUIET is actually useless.
Setting QUIET may speed-up the search significantly, simply due to
the fact that text output is a bit slow on some configurations.
PRINTSEARCHED
Find prints a list of the directories it searched in.
PRINTSKIPPED
Same as PRINTSEARCHED but will print a list of the directories it
skipped.
LFORMAT or FORMAT
This is similar to the c:list argument LFORMAT. The given string is
written to the output for every matching object. The following commands
are supported:
%s - inserts full path and name of the object
%n - inserts the name of the object
%p - inserts the _full_ path of the object. This is different to
c:lists` %p which prints the path relative to the current
directory.
Example:
Find EggPaint#? format "Found the magnificent %n in %p."
might output
Found the magnificent EggPaint in My First Disk:Gfx.
NOTE:
Find² now automatically appends a carriage return to the end of
the string. This is different to version 1.
Stop-That-Work® Option
======================
Pressing ctrl-c will do a full stop, ctrl-e will stop the current
directory scan only.
Return Codes
============
Code Level Meaning
0 No matching objects found.
5 warn Object(s) found - number is in local variable Result2.
You can use c:get to read it.
10 error One or more LOCATIONs not found.
20 fail Usually out-of-memory condition.
21 " Arguments didn`t match.
22 " Wildcards in PATTERN are not valid or a path was given.
23 " Either wildcard problem or something went wrong while
searching for matching directories.
30 " Virus Warning.
Copyright
=========
Find, Find.readme and Find.doc:
Copyright 1997 by Sönke Tesch
All Rights Reserved.
You may re-distribute the archive as long as no file is removed or
changed.
Find has to be distributed for FREE, any other kind of distribution
without my written permission is not allowed. However, this is not
the case for any AmiNet-CD. Others please feel free to ask.
I do not give any guarantee for the quality and usefulness of Find
nor that it works as described or fits particular needs.
Contact
=======
Comments, suggestions, bug-reports and Hey-I-use-it!-mails are
always welcome! Just write to <soenke@vapor.com>.
Those finer details..
=====================
Find features a simple build-in virus self-protection.
Find is written using Cyclone Modula-2 by Marcel Timmermans.
The source is available on request, just ask.
Find is still smaller than this document :)
History
=======
03-Oct-99 2.04 + replaced * with ! (* may be used as #? replacement)
+ a few cosmetical optimizations (breaks and "Scanning..")
06-Aug-97 2.03 ¤ bugfix in DoDir()
+ even more optimizations
¤ viruscheck wasn`t enabled (boo:)
a released on Aminet
21-Jul-97 2.02 ¤ Fixed bug in output routine (didn`t clear lines)
+ various optimizations to get size below the magic 5k
+ returns error if PATTERN is a path
¤ (hopefully) solved problem that ctrl-e didn`t work
from time to time
a released on Aminet
10-Jul-97 2.01 + Total number of found objects returned in Result2
+ Fixed return codes so that they better match the
system standards
¤ Although I wrote it wouldn`t QUIET did suppress
output of PRINTSKIPPED and PRINTSEARCHED
+ Non-existing LOCATIONs return error code 10
09-Jul-97 2.00 + added * to control search
+ FORMAT now supports %n and %p
+ PRINTSKIPPED & PRINTSEARCHED
a non-public gamma release
08-Jul-97 2.00 + search locations may be controlled by + and -
19-May-97 1.00 a Version 1.00 on Aminet
Have fun,
soenk.e
--
Amiga Translators Organization * Main & German Admin, Ex-Human Listserver
ato : ato-admin-de@ato.vapor.com & ato-admin@ato.vapor.com
private: soenke@vapor.com